﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Fatec.ControleEstoque.Security.Providers;
using Fatec.ControleEstoque.Data.Model;
using System.Web.DynamicData;

namespace Fatec.ControleEstoque.Interface
{
    public partial class Menu1 : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                InserirItens(HttpContext.Current.User.Identity.Name);
            }
        }

        protected void InserirItens(String userName)
        {
            if (String.IsNullOrEmpty(userName))
            {
                this.menu.Items.Clear();
                return;
            }
            foreach (MetaTable t in MetaModel.Default.VisibleTables)
            {
                ListItem l = new ListItem();
                l.Text = t.DisplayName;
                l.Value = t.ListActionPath;
                this.menu.Items.Insert(this.menu.Items.Count-1, l);
            }
        }
    }
}